package org.zheng.shop.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.zheng.shop.entity.Product;

import java.util.List;

@Repository
public interface ProductRepository extends JpaRepository<Product, Integer> {
    List<Product> findAllByOrderByPriorityDesc();
    
    List<Product> findByCategoryIdOrderByPriorityDesc(Integer categoryId);
    
    @Query(value = "SELECT * FROM products ORDER BY create_time DESC LIMIT ?1", nativeQuery = true)
    List<Product> findLatestProducts(Integer limit);
} 